package com.fangyi.yunmusic.advice;

import com.fangyi.yunmusic.exception.YunMusicException;
import com.fangyi.yunmusic.utils.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class YunMusicControllerAdvice {

    // 统一异常处理
    @ExceptionHandler(value = YunMusicException.class)
    @ResponseBody
    public JsonResult errorHandle(Exception ex) {
        return JsonResult.errorMsg(ex.getMessage());
    }
}
